package com.dream.java_concurrency.test;

import org.junit.jupiter.api.Test;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class ThreadTest01 {

    @Test
    public void test1() {
        Thread t1 = new Thread(() -> {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("thread 1");
            System.out.println("aa");
        });
        t1.start();
        System.out.println("1");
    }

    public void test2() {
        // test io


        try (InputStream is = new FileInputStream("")) {
            int read = is.read();
        } catch (IOException ioe) {
            // ignore
        }


    }
}

class Task1 implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("第" + i + "次");
        }
    }
}